# config_loader.py
import yaml
import torch
import pandas as pd
import utils.utils as utils


class Config2:
    def __init__(self, yaml_path="./configs/config.yaml"):
        with open(yaml_path, "r") as f:
            cfg = yaml.safe_load(f)

        self.env = cfg["env"]
        self.patchtst = cfg["patchtst"]
        self.agent = cfg["agent"]

        self.agent["device"] = torch.device(
            self.agent["device"] if torch.cuda.is_available() else "cpu"
        )

        self.env["df"] =utils.process_futures_data_blc(futures_list = self.env['futures'] , folder_path = "./data/tech").transpose(1,0,2)



        self.env["if_train"] = self.env["if_train"]
        self.env["initial_future"] = (
            None if self.env["initial_future"] == "None" else self.env["initial_future"]
        )
        self.env["reward_scaling"] = eval(self.env["reward_scaling"])
